package com.baizhi.llw.controller;

import com.baizhi.llw.entity.Admin;
import com.baizhi.llw.service.AdminServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.Map;

@Controller
@CrossOrigin
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminServiceImpl adminServiceImpl;
    @ResponseBody
    @RequestMapping("/getImageCodes")
   public Map<String,String> getImageCodes() throws IOException {
        return adminServiceImpl.getImageCodes();
    }
    @ResponseBody
    @RequestMapping("/login")
   public Map<String,String> login(@RequestBody Admin admin,String token){
        return adminServiceImpl.login(admin,token);
    }
    @ResponseBody
    @RequestMapping("/selectOne")
    public Admin selectOne(String token){
        return adminServiceImpl.queryOne(token);
    }
    @ResponseBody
    @RequestMapping("/getUserInfo")
    public Admin getUserInfo(String token){
        return adminServiceImpl.getUserInfo(token);
    }
    @ResponseBody
    @RequestMapping("/logout")
    public void logout(String token){
        adminServiceImpl.logout(token);
    }
}
